package cn.iocoder.yudao.module.system.service.social.authsource;

import cn.iocoder.yudao.module.system.service.social.authrequest.AuthAlipayRequestV2;
import com.xingyuv.jushauth.config.AuthSource;
import com.xingyuv.jushauth.request.*;

/**
 * Description:
 * Author: li
 * Date: 2024/2/28
 */
public enum AuthDefaultSourceV2 implements AuthSource {
    ALIPAY_V2 {
        @Override
        public String authorize() {
            return "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm";
        }

        @Override
        public String accessToken() {
            return "https://openapi.alipay.com/gateway.do";
        }

        @Override
        public String userInfo() {
            return "https://openapi.alipay.com/gateway.do";
        }

        @Override
        public Class<? extends AuthDefaultRequest> getTargetClass() {
            // 修改为AuthAlipayRequestV2，兼容openId
            return AuthAlipayRequestV2.class;
        }
    },

    WECHAT_MINI_APP {
        public String authorize() {
            throw new UnsupportedOperationException("不支持获取授权 url，请使用小程序内置函数 wx.login() 登录获取 code");
        }

        public String accessToken() {
            return "https://api.weixin.qq.com/sns/jscode2session";
        }

        public String userInfo() {
            throw new UnsupportedOperationException("不支持获取用户信息 url，请使用小程序内置函数 wx.getUserProfile() 获取用户信息");
        }

        public Class<? extends AuthDefaultRequest> getTargetClass() {
            return null;
        }
    };
}
